/**
* @file componentSelection.h
* @author Alberto Basso, Luca Tumelero
* @brief Set of methods for component selection
*/

#ifndef COMPONENTSELECTION_H
#define COMPONENTSELECTION_H

#include <cmath>
#include <vector>
#include <string>
#include <sstream>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/search/kdtree.h>
#include <pcl/segmentation/extract_clusters.h>

using namespace std;


/**
 * @brief Performs a cluster segmentation on the input cloud from the selectedPointIndex and returns the pointIndices of the cluster found
 *
 * @param[in] input Input cloud
 * @param[out] output Vector of index of the component
 * @param[in] selectedPointIndex Index of a point inside the cluster of interest
 * @param[in] threshold Threshold for cluster segmentation
 */
void segmentCluster
(
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr input,
    pcl::PointIndices::Ptr output,
    int selectedPointIndex,
    double threshold
);

/**
 * @brief Performs a color segmentation on the input cloud from the selectedPointIndex and returns the pointIndices of the cluster found
 *
 * @param[in] input Input cloud
 * @param[out] output Vector of index of the component
 * @param[in] selectedPointIndex Index of a point inside the cluster of interest
 * @param[in] threshold Threshold of colors
 */
void segmentColor
(
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr input,
    pcl::PointIndices::Ptr output,
    int selectedPointIndex,
    int threshold
);

/**
 * @brief  Returns the intersection of two point indices vectors.
 *
 * @param[in] first First indices vector
 * @param[in] second Second indices vector
 * @param[out] intersection Intersecion of the two vectors
 */
void intersectIndices
(
    pcl::PointIndices::Ptr first,
    pcl::PointIndices::Ptr second,
    pcl::PointIndices::Ptr intersection
);
#endif
